import org.wwx.protocol.HttpService;
import org.wwx.register.LocalRegister;
import org.wwx.register.core.LightweightRegistry;
import org.wwx.register.model.ServiceInstance;

/**
 * @date 2025/6/5
 * @author王闻薪
 */
public class Provider {
    public static void main(String[] args) {
        // 本地的注册中心
        LocalRegister.register(HelloService.class.getName(),HelloServiceImpl.class);

//        final URL url = new URL("localhost", 1128);
//
//        MapRemoteRegister.register(HelloService.class.getName(),url);


        try {
            // 创建注册中心客户端
            LightweightRegistry registry = new LightweightRegistry.Builder()
                    .withBuiltInHttpServer(8080) // 注册中心端口
                    .build();

            // 注册服务到注册中心
            registry.registerService(
                    HelloService.class.getName(),
                    new ServiceInstance("localhost", 1128)
            );

            new HttpService().start("localhost", 1128);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
